package com.own.business.message.center.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.own.business.message.center.business.service.MessageCenterGroupService;
import com.own.business.message.center.entity.bo.MessageCenterGroupBo;
import com.own.business.message.center.entity.map.MessageCenterGroupMapVo;
import com.own.business.message.center.entity.po.MessageCenterGroup;
import com.own.business.message.center.entity.query.MessageCenterGroupQuery;
import com.own.business.message.center.entity.vo.MessageCenterGroupVo;
import com.own.business.message.center.mapper.MessageCenterGroupMapper;
import com.own.component.common.base.service.impl.AbstractBaseService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * MessageCenterGroupServiceImpl
 *
 * @author chenxueli
 * @date 2023-11-13 14:39:27
 */
@Slf4j
@Service
public class MessageCenterGroupServiceImpl extends AbstractBaseService<
        MessageCenterGroup,
        MessageCenterGroupBo,
        MessageCenterGroupVo,
        MessageCenterGroupMapVo,
        MessageCenterGroupQuery,
        MessageCenterGroupMapper
        > implements MessageCenterGroupService {

    @Resource
    private MessageCenterGroupMapper messageCenterGroupMapper;

    /**
     * 获取查询条件
     *
     * @param query 查询条件
     * @return 查询条件对象
     */
    @Override
    public LambdaQueryWrapper<MessageCenterGroup> lambdaQueryWrapper(MessageCenterGroupQuery query) {
        return super.lambdaQueryWrapper(query)
                .eq(query.getIsShow() != null, MessageCenterGroup::getIsShow, query.getIsShow())
                .eq(StringUtils.isNotBlank(query.getGroupKey()), MessageCenterGroup::getGroupKey, query.getGroupKey())
                .like(StringUtils.isNotBlank(query.getName()), MessageCenterGroup::getName, query.getName())
                .orderByAsc(MessageCenterGroup::getSortOrder);
    }

}
